package graphics;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.util.ResourceBundle;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

/**
 *
 * @author mateusz
 */
public class CustomWindow extends JFrame {

    /**
     * 
     */
    protected JPanel mainPanel;
    /**
     * 
     */
    protected ResourceBundle rb;

    /**
     * Creates new custom window
     * @param name      name of custom window
     * @param size      size of custom window
     * @param position  position of custom window
     */
    public CustomWindow( String name, Dimension size, Point position ) {
        this( name, size.width, size.height, position.x, position.y );
    }

    /**
     * Creates new custom window
     * @param name      name of custom window
     * @param width     width of custom window
     * @param height    height of custom window
     * @param posX      position X (horizontal) of custom window
     * @param posY      position Y (vertical) of custom window
     */
    public CustomWindow( String name, int width, int height, int posX, int posY ) {
        dispose();
        setName( name );
        setTitle( name );
        setDefaultLookAndFeelDecorated( false );            // hide all decorations
        setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );   // exit from application when user close this window
        setSize( width, height );
        setLocation( posX, posY );
        setResizable( false );
        setUndecorated( true );
        setVisible( true );
        
        //addMainPanel();
    }

    /**
     * Creates new main panel with black line border and adds it to content pane
     */
    protected void addMainPanel() {
        // set main panel, maintaining whole window
        mainPanel = new JPanel();
        // set panel border
        mainPanel.setBorder( new LineBorder( Color.black ) );
        
        // add main panel to content pane
        //getContentPane().add( mainPanel );
        add(mainPanel);
    }

    /**
     * Returns main panel of custom window
     * @return main panel of window
     */
    public JPanel getMainPanel() {
        return mainPanel;
    }

    /**
     * Set main panel of window
     * @param panel panel to set as main
     */
    public void setMainPanel( JPanel panel ) {
        mainPanel = panel;
    }

    public static void setPanelSize(JPanel panel, Dimension size){
        panel.setMinimumSize(size);
        panel.setMaximumSize(size);
        panel.setSize(size);
        panel.setPreferredSize(size);
    }
}
